import { Define, EntityObjectFactory } from 'tiny-entity2';
const EntityObjectType = EntityObjectFactory.GetEntityObjectType(process.env.dataBaseType || 'mysql');
import { ComboGroupItem } from './comboGroupItem';
import { ComboGroupRule } from './comboGroupRule';

@Define.Table({ TableName: 'combogroup' })
export class ComboGroup extends EntityObjectType<ComboGroup> {
    @Define.PrimaryKey()
    id: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    comboId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    productId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    name: string;

    @Define.Mapping({
        Mapping: 'ComboGroupRule',
        MappingKey: { FKey: 'comboGroupId', MKey: 'id' },
        MappingType: Define.MappingType.One
    })
    comboGroupRule: ComboGroupRule;

    @Define.Mapping({
        Mapping: 'ComboGroupItem',
        MappingKey: 'comboGroupId'
    })
    comboGroupItems: ComboGroupItem[];

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    storeId: string;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    createTime: number;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    version: number;
}